{template paome_header}
<link rel="stylesheet" href="static/calendar/js/calendar.css" />
<script type="text/javascript" charset="utf-8" src="static/calendar/calendar.php"></script>

<link rel="stylesheet" href="/static/kindeditor/themes/default/default.css" />
<script charset="utf-8" src="/static/kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="/static/kindeditor/lang/zh_CN.js"></script>

<style type="text/css">
    .bg{display:none;position:fixed;width:100%;height:100%;background:#000;z-index:2;top:0;left:0;opacity:0.7;}
</style>
<h4 style="padding-left:10px;;">
    <a href="?c=paome_index&a=getPaomeList"><span>赛季列表</span></a>
    >>
    {if $paomeId>0}
        <a href="?c=paome_index&a=addPaome&paomeId={$paomeId}"><span>编辑赛季</span></a>
    {else}
        <a href="?c=paome_index&a=addPaome"><span>新增赛季</span></a>
    {/if}
</h4>
<script type="text/javascript">
    function uploadImage() {
        if($("#imgFile").val() != '') $("#upload_form").submit();
    }
    function upload_frame_load() {
        var data = $(window.frames['upload_frame'].document.body).html();
        if(data) {
            data = eval('(' + data + ')');
            //console.log(data);return false;
            if(data.status=='ok'){
                var _this= $('#showImage');_num = _this.find('img').length;
                var _html = '';
                if (_num && (_num % 5) == 0) {
                    _html +='<br />';
                }
                 _html +=
                        '<span style="margin: 10px  10px 10px 10px">'
                        +'<img src="'+ data.image+'" style="width: 100px;height: 100px;">'
                        +'<input type="hidden" name="image[]" value="'+data.image+'" />'
                        +'</span>'
                        +'<span class="btn btn-primary delimages" >删除</span>';

                $('#showImage').html(_html);
            }else{
                alert(data.error_msg);
            }
        }
    }

    $(function () {
        KindEditor.ready(function (K) {
            K.create('textarea[name="introduce"]', {
                allowFileManager: true,
                uploadJson: './index.php?c=admin&a=uploadKindEditorImg',
                newlineTag: 'p',
                filterMode: true,
                htmlTags: {
                    p: ['style', 'color', 'align', 'class'],
                    font: ['style', 'color', 'size', 'face', 'class'],
                    span: ['style', 'style', 'color', 'align'],
                    div: ['style', 'class', 'align'],
                    a: ['style', 'class', 'href', 'target', 'name'],
                    embed: ['style', 'src', 'width', 'height', 'type', 'loop', 'autostart', 'quality',
                        'style', 'align', 'allowscriptaccess', '/'],
                    img: ['style', 'src', 'width', 'height', 'border', 'alt', 'title', 'align', 'style', 'data-source', '/', 'class'],
                    hr: ['style', 'class', '/'],
                    br: ['/'],
                    'ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6': ['style', 'align'],
                    'tbody,tr,strong,b,sub,sup,em,i,u,strike,section': ['style', 'class'],
                },
                afterBlur: function () {
                    this.sync();
                }
            });
            K.create('textarea[name="introduce2"]', {
                allowFileManager: true,
                uploadJson: './index.php?c=admin&a=uploadKindEditorImg',
                newlineTag: 'p',
                filterMode: true,
                htmlTags: {
                    p: ['style', 'color', 'align', 'class'],
                    font: ['style', 'color', 'size', 'face', 'class'],
                    span: ['style', 'style', 'color', 'align'],
                    div: ['style', 'class', 'align'],
                    a: ['style', 'class', 'href', 'target', 'name'],
                    embed: ['style', 'src', 'width', 'height', 'type', 'loop', 'autostart', 'quality',
                        'style', 'align', 'allowscriptaccess', '/'],
                    img: ['style', 'src', 'width', 'height', 'border', 'alt', 'title', 'align', 'style', 'data-source', '/', 'class'],
                    hr: ['style', 'class', '/'],
                    br: ['/'],
                    'ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6': ['style', 'align'],
                    'tbody,tr,strong,b,sub,sup,em,i,u,strike,section': ['style', 'class'],
                },
                afterBlur: function () {
                    this.sync();
                }
            });
        });
    })

</script>
<div id="fream">
    <form id="upload_form" method="post" action="?c=paome_index&a=ajaxUploadImage" target="upload_frame" enctype="multipart/form-data">
        <input type="file" name="imgFile" id="imgFile" style="display:none;" onchange="uploadImage();">
    </form>
    <iframe id="upload_frame" name="upload_frame" style="display:none" onLoad="upload_frame_load();"></iframe>
</div>
<form class="form-horizontal"  action="?c=paome_index&a=ajaxAddPaome"  id="tr_form">
    <div class="control-group">
        <label class="control-label" >赛季标题：</label>
        <div class="controls">
            <input type="text" value="{if isset($info['title'])}{$info['title']}{/if}" name="name" placeholder="请输入标题" />
        </div>
    </div>
    <div class="control-group">
        <label class="control-label" >  缩略图：</label>
        <div class="controls">
            <button type="button" id="file_upload_btn" class="btn btn-primary" onclick="$('#imgFile').trigger('click')">
                <i class="ace-icon fa fa-cloud-upload bigger-110"></i>上传图片
            </button>
        </div>
    </div>
    <div class="control-group">
        <div class="controls" id="showImage">
            {if isset($info['image'])}
            <span style="margin: 10px  10px 10px 10px">
             <img src="{$info['image']}" style="width: 100px;height: 100px;">
             <input type="hidden" name="image[]" value="{$info['image']}" />
            </span>
            <span class="btn btn-primary delimages" >删除</span>
            {/if}
        </div>
    </div>

    <div class="control-group">
        <label class="control-label" >缩略图文案：</label>
        <div class="controls">
            <input type="text" value="{if isset($info['image_text'])}{$info['image_text']}{/if}" name="imageText" placeholder="请输入缩略图上需要显示的文案" />
        </div>
    </div>

    <div class="control-group">
        <label class="control-label" >俱乐部成员数量：</label>
        <div class="controls">
            <input type="text" value="{if isset($info['min_num'])}{$info['min_num']}{/if}" name="minNum" placeholder="上限" />
            —
            <input type="text" value="{if isset($info['max_num'])}{$info['max_num']}{/if}" name="maxNum" placeholder="下限" />
        </div>
    </div>

    <div class="control-group">
        <label class="control-label" >入选决赛百分比：</label>
        <div class="controls">
            <!--预留-->
            <!--  <select name="rate_type">
                  <option value="0">百分比</option>
                  <option value="5" {if isset($info['rate_type']) && $info['rate_type']==5}selected{/if}>俱乐部数量（前N名）</option>
              </select>-->
            <input type="text" value="{if isset($info['rate'])}{$info['rate']}{/if}" name="rate" placeholder="百分比范围>0,<=100,最多1位小数" />
        </div>
    </div>

    <div class="control-group">
        <label class="control-label" >时间：</label>

        <div class="controls">
            活动发布时间：
            <input type="text" name="signTime" id="date_time_id" value="{if isset($info['formatSignTime'])}{$info['formatSignTime']}{/if}" readonly="readonly" placeholder="开始时间">　
            <button name="date_time_btn" type="button" id="date_time_btn" onclick="return showCalendar('date_time_id', '%Y-%m-%d %H:%M:%S', '24', false, 'date_time_btn');" class="button" id="date_time_id"/>选择</button>
        </div>
        <br />
        <div class="controls">
            预选赛开始时间：
            <input type="text" name="startTime" id="date_time_id2" value="{if isset($info['formatStartTime'])}{$info['formatStartTime']}{/if}" readonly="readonly" placeholder="开始时间">　
            <button name="date_time_btn2" type="button" id="date_time_btn2" onclick="return showCalendar('date_time_id2', '%Y-%m-%d 00:00:00', '24', false, 'date_time_btn2');" class="button" id="date_time_id"/>选择</button>
        </div>
        <br />
        <div class="controls">
            争霸赛结束时间：
            <input type="text" name="endTime" id="date_time_id3" value="{if isset($info['formatEndTime'])}{$info['formatEndTime']}{/if}" readonly="readonly" placeholder="结束时间">　
        </div>
    </div>

    <!--<div class="control-group">-->
        <!--<label class="control-label" >第一轮：</label>-->

        <!--<div class="controls">-->
            <!--预赛：-->
            <!--<input type="text" name="startTime[]" id="date_time_id" value="{if isset($info['formatStartTime'])}{$info['formatStartTime']}{/if}" readonly="readonly" placeholder="开始时间">　-->
            <!--<button name="date_time_btn" type="button" id="date_time_btn" onclick="return showCalendar('date_time_id', '%Y-%m-%d %H:%M:%S', '24', false, 'date_time_btn');" class="button" id="date_time_id"/>选择</button>-->
            <!--—-->
            <!--<input type="text" name="endTime[]" id="date_time_id2" value="{if isset($info['formatStartTime'])}{$info['formatStartTime']}{/if}" readonly="readonly" placeholder="结束时间">　-->
            <!--<button name="date_time_btn" type="button" id="date_time_btn2" onclick="return showCalendar('date_time_id2', '%Y-%m-%d %H:%M:%S', '24', false, 'date_time_btn');" class="button" id="date_time_id"/>选择</button>-->
        <!--</div>-->
       <!--<br />-->
        <!--<div class="controls">-->
            <!--决赛：-->
            <!--<input type="text" name="startTime_2[]" id="date_time_id3" value="{if isset($info['formatStartTime'])}{$info['formatStartTime']}{/if}" readonly="readonly" placeholder="开始时间">　-->
            <!--<button name="date_time_btn" type="button" id="date_time_btn3" onclick="return showCalendar('date_time_id3', '%Y-%m-%d %H:%M:%S', '24', false, 'date_time_btn');" class="button" id="date_time_id"/>选择</button>-->
            <!--—-->
            <!--<input type="text" name="endTime_2[]" id="date_time_id4" value="{if isset($info['formatStartTime'])}{$info['formatStartTime']}{/if}" readonly="readonly" placeholder="结束时间">　-->
            <!--<button name="date_time_btn" type="button" id="date_time_btn4" onclick="return showCalendar('date_time_id4', '%Y-%m-%d %H:%M:%S', '24', false, 'date_time_btn');" class="button" id="date_time_id"/>选择</button>-->
        <!--</div>-->
    <!--</div>-->

    <!--<div class="control-group">-->
        <!--<label class="control-label" >第二轮：</label>-->
        <!--<div class="controls">-->
            <!--预赛：-->
            <!--<input type="text" name="startTime[]" id="date_time_id5" value="{if isset($info['formatStartTime'])}{$info['formatStartTime']}{/if}" readonly="readonly" placeholder="开始时间">　-->
            <!--<button name="date_time_btn" type="button" id="date_time_btn5" onclick="return showCalendar('date_time_id5', '%Y-%m-%d %H:%M:%S', '24', false, 'date_time_btn');" class="button" id="date_time_id"/>选择</button>-->
            <!--—-->
            <!--<input type="text" name="endTime[]" id="date_time_id6" value="{if isset($info['formatStartTime'])}{$info['formatStartTime']}{/if}" readonly="readonly" placeholder="结束时间">　-->
            <!--<button name="date_time_btn" type="button" id="date_time_btn6" onclick="return showCalendar('date_time_id6', '%Y-%m-%d %H:%M:%S', '24', false, 'date_time_btn');" class="button" id="date_time_id"/>选择</button>-->
        <!--</div>-->
        <!--<br />-->
        <!--<div class="controls">-->
            <!--决赛：-->
            <!--<input type="text" name="startTime_2[]" id="date_time_id7" value="{if isset($info['formatStartTime'])}{$info['formatStartTime']}{/if}" readonly="readonly" placeholder="开始时间">　-->
            <!--<button name="date_time_btn" type="button" id="date_time_btn7" onclick="return showCalendar('date_time_id7', '%Y-%m-%d %H:%M:%S', '24', false, 'date_time_btn');" class="button" id="date_time_id"/>选择</button>-->
            <!--—-->
            <!--<input type="text" name="endTime_2[]" id="date_time_id8" value="{if isset($info['formatStartTime'])}{$info['formatStartTime']}{/if}" readonly="readonly" placeholder="结束时间">　-->
            <!--<button name="date_time_btn" type="button" id="date_time_btn8" onclick="return showCalendar('date_time_id8', '%Y-%m-%d %H:%M:%S', '24', false, 'date_time_btn');" class="button" id="date_time_id"/>选择</button>-->
        <!--</div>-->
    <!--</div>-->

    <!--<div class="control-group">-->
        <!--<label class="control-label" >第三轮：</label>-->
        <!--<div class="controls">-->
            <!--预赛：-->
            <!--<input type="text" name="startTime[]" id="date_time_id9" value="{if isset($info['formatStartTime'])}{$info['formatStartTime']}{/if}" readonly="readonly" placeholder="开始时间">　-->
            <!--<button name="date_time_btn" type="button" id="date_time_btn9" onclick="return showCalendar('date_time_id9', '%Y-%m-%d %H:%M:%S', '24', false, 'date_time_btn');" class="button" id="date_time_id"/>选择</button>-->
            <!--—-->
            <!--<input type="text" name="endTime[]" id="date_time_id10" value="{if isset($info['formatStartTime'])}{$info['formatStartTime']}{/if}" readonly="readonly" placeholder="结束时间">　-->
            <!--<button name="date_time_btn" type="button" id="date_time_btn10" onclick="return showCalendar('date_time_id10', '%Y-%m-%d %H:%M:%S', '24', false, 'date_time_btn');" class="button" id="date_time_id"/>选择</button>-->
        <!--</div>-->
        <!--<br />-->
        <!--<div class="controls">-->
            <!--决赛：-->
            <!--<input type="text" name="startTime_2[]" id="date_time_id11" value="{if isset($info['formatStartTime'])}{$info['formatStartTime']}{/if}" readonly="readonly" placeholder="开始时间">　-->
            <!--<button name="date_time_btn" type="button" id="date_time_btn11" onclick="return showCalendar('date_time_id11', '%Y-%m-%d %H:%M:%S', '24', false, 'date_time_btn');" class="button" id="date_time_id"/>选择</button>-->
            <!--—-->
            <!--<input type="text" name="endTime_2[]" id="date_time_id12" value="{if isset($info['formatStartTime'])}{$info['formatStartTime']}{/if}" readonly="readonly" placeholder="结束时间">　-->
            <!--<button name="date_time_btn" type="button" id="date_time_btn12" onclick="return showCalendar('date_time_id12', '%Y-%m-%d %H:%M:%S', '24', false, 'date_time_btn');" class="button" id="date_time_id"/>选择</button>-->
        <!--</div>-->
    <!--</div>-->

    <!--<div class="control-group">-->
        <!--<label class="control-label" >冠军争霸赛：</label>-->
        <!--<div class="controls">-->
            <!--<input type="text" name="startTime[]" id="date_time_id13" value="{if isset($info['formatStartTime'])}{$info['formatStartTime']}{/if}" readonly="readonly" placeholder="开始时间">　-->
            <!--<button name="date_time_btn" type="button" id="date_time_btn13" onclick="return showCalendar('date_time_id13', '%Y-%m-%d %H:%M:%S', '24', false, 'date_time_btn');" class="button" id="date_time_id"/>选择</button>-->
            <!--—-->
            <!--<input type="text" name="endTime[]" id="date_time_id14" value="{if isset($info['formatStartTime'])}{$info['formatStartTime']}{/if}" readonly="readonly" placeholder="结束时间">　-->
            <!--<button name="date_time_btn" type="button" id="date_time_btn14" onclick="return showCalendar('date_time_id14', '%Y-%m-%d %H:%M:%S', '24', false, 'date_time_btn');" class="button" id="date_time_id"/>选择</button>-->
        <!--</div>-->
    <!--</div>-->

    <div class="control-group">
        <label class="control-label" >竞赛规则详细说明：</label>
        <div class="controls">
            <textarea rows="10" name="introduce" style="width:800px; min-height:200x;">
                {if isset($info['introduce'])}{$info['introduce']}{/if}
            </textarea>
        </div>
    </div>
    {if $paomeId>0}
    {else}
    <div class="control-group">
        <div class="controls">
            <input type="hidden" name="paomeId" value="{$paomeId}"/>
            <span class="btn btn-primary" type="button" id="qd">确定</span>
        </div>
    </div>
    {/if}

</form>
{template footer}
<script type="text/javascript">
    $(document).on("click",".delimages", function () {
        var _this=$(this),_del = $(this).prev('span');
        _del.remove();
        _this.remove();
    })
    /*争霸赛结束时间联动*/
    $(document).on("change","#date_time_id2", function () {
        alert(11);
        $("input[name='startTime']").val('');
        var _this =  $("input[name='startTime']");
        if (_this.val()) {
            curDate = new Date();
            var nextDate = new Date(curDate.getTime() + 39*24*60*60*1000);  //后一天
            $("input[name='startTime']").val(_this.val(nextDate));
        };
    })

    $('#qd').on('click',function(){
        $.ajax({
            type:'POST',
            url:$('#tr_form').attr('action'),
            data:$('#tr_form').serialize(),
            dataType:'json',
            success:function(d){
                if(d.status=='ok'){
                    alert(d.error_msg);
                    window.location.href=d.url;
                }else{
                    alert(d.error_msg);
                }
            }
        })
    })
</script>